﻿/**
 * @file InpNastranReaderHelper.h
 * @author zhourp (zhourunping@diso.cn)
 * @brief the helper of interpreting bdf
 * @date 2024-11-14
 */
#ifndef INPNASTRANREADERHELPER_H
#define INPNASTRANREADERHELPER_H

#include "FITKNastranBDFReader.h"

#include "FITK_Component/FITKAbaqusData/FITKAbaqusPart.h"
#include "FITK_Component/FITKAbaqusData/FITKDataCase.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMeshPartVTK.h"

#include <QMap>

namespace Nastran
{
/**
 * @brief the helper of interpreting bdf
 * 
 * @author: zhourp (zhourunping@diso.cn)
 * @date: 2024-11-14
 */
class InpNastranReaderHelper
{
  public:
    /**
     * @brief Constructor for InpNastranReaderHelper, initializes member variables.
     * @param [i] caseData Pointer to AbaqusData::FITKDataCase, containing the analysis case data.
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-15
     */
    explicit InpNastranReaderHelper(AbaqusData::FITKDataCase *caseData);
    ~InpNastranReaderHelper();

    /**
     * @brief Inserts the cell ID into the specified group in the grouping information map.
     *
     * This function adds a cell ID to the list of cells associated with a specific group ID in the grouping information
     * map.
     *
     * @param[in] groupID The ID of the group to which the cell belongs.
     * @param[in] cellID The ID of the cell to be inserted.
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    void insertCellsGroupInfo(int groupID, int cellID);

    /**
     * @brief Constructs groups with sections for the given part in the Nastran model.
     *
     * This function processes the grouping information and creates element groups
     * associated with sections for the specified part. It involves creating model sets,
     * assigning sections, and managing data objects within the part's component and
     * section assignment managers.
     *
     * @param[in] part Pointer to the Abaqus part for which groups with sections are to be constructed.
     * @return True if the construction is successful, false otherwise.
     *
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    bool constructGroupWithSection(AbaqusData::FITKAbaqusPart *part);

    /**
     * @brief Sets the reader object for the InpNastranReaderHelper.
     *
     * This function assigns a FITKNastranBDFReader pointer to the internal reader variable of the
     * InpNastranReaderHelper class.
     *
     * @param[in] reader Pointer to the FITKNastranBDFReader object.
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    void setReader(FITKNastranBDFReader *reader);

  private:
    /**
     * @brief 算例数据
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    AbaqusData::FITKDataCase *_caseData{};

    /**
     * @brief group information
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    QMap<int, QList<int>> _groupingInfo{};

    /**
     * @brief BDF文件读取器
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    FITKNastranBDFReader *_reader{};
};
} // namespace Nastran
#endif // INPNASTRANREADERHELPER_H
